#get the most carrier agent make flights
most_aircraft_flights=carrier_delay_df2.sort_values(by='arr_flights',ascending=False )
most_aircraft_flights.plot(kind="bar",x='carrier_name',y='arr_flights',figsize=(20,10)),sorted
print(most_aircraft_flights['arr_flights'].mean())
plt.show()
1470.2529333333332
#get the most carrier agent make delay
most_aircraft_delay=carrier_delay_df2.sort_values(by='aircraft_delay(min/flight)',ascending=False )
most_aircraft_delay.plot(kind="bar",x='carrier_name',y='aircraft_delay(min/flight)',figsize=(20,10)),sorted
print(most_aircraft_delay['aircraft_delay(min/flight)'].mean())
plt.show()
53.01640733771036
#get the most carrier agent make delay more than def_avg_Delay
carrier_delay_df2['def_avg_Delay'] = (carrier_delay_df2['def_avg_Delay'] / 1000)
carrier_delay_df2.plot(kind='area',x='carrier_name',y='def_avg_Delay', color='red',stacked=False ,figsize=(20,10)),sorted
print(most_aircraft_delay['def_avg_Delay'].mean())
plt.show()
5675511.9000122715
#us airport distribution by state and Weather Delay info
fig = px.scatter_mapbox(geo, lat="LATITUDE", lon="LONGITUDE", hover_name="AIRPORT_STATE_NAME", hover_data=["AIRPORT_STATE_NAME", "weather_delay(min/flight)"],
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
#get the most airports makeing weather_delay
most_airports_delay=geo.sort_values(by='weather_delay(min/flight)',ascending=False )
most_airports_delay.head(20).plot(kind="bar",x='DISPLAY_AIRPORT_NAME',y='weather_delay(min/flight)',figsize=(20,10)),sorted
print(geo['weather_delay(min/flight)'].mean())
plt.show()
7.83864917649772
#us airport distribution by state and Weather Delay info #using Google API Maps #map view
locations = geo[['LATITUDE', 'LONGITUDE']]
weights = geo['weather_delay(min/flight)']
fig = gmaps.figure()
fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
fig
geo.plot(kind="scatter", x="LONGITUDE", y="LATITUDE",
s=geo['arr_cancelled'], label="Flight Cancelled",
c="arr_cancelled", cmap=plt.get_cmap("jet"),
colorbar=True, alpha=0.4, figsize=(20,10),
)
plt.legend()
plt.show()
#us airport distribution by state and Weather Delay info #using Google API Maps #satellite view
locations = df_geo_1[['LATITUDE', 'LONGITUDE']]
weights = df_geo_1['carrier_delay(min/flight)']
fig = gmaps.figure()
fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
fig
#get the most state makeing weather_delay
most_state_delay=most_state_delay.sort_values(by='weather_delay(min/flight)',ascending=False )
most_state_delay.plot(kind="bar",x='STATE_NAME',y='weather_delay(min/flight)',figsize=(20,10)),sorted
print(most_state_delay['weather_delay(min/flight)'].mean())
plt.show()
39.75564591352922
#us state and Weather Delay info #using Google API Maps #satellite view
locations = most_state_delay[['latitude', 'longitude']]
weights = most_state_delay['weather_delay(min/flight)']
fig = gmaps.figure()
fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
fig